{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 基于核方法的支持向量机分类器\n",
    "from sklearn.svm import SVC # 导入支持向量机分类器\n",
    "from sklearn.datasets import make_gaussian_quantiles # 导入生成高斯分布数据集的函数\n",
    "from sklearn.model_selection import train_test_split # 导入数据集划分函数\n",
    "from sklearn.metrics import accuracy_score # 导入准确率计算函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9777777777777777"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X, y = make_gaussian_quantiles(n_features=2, n_classes=2, n_samples=300) # 生成高斯分布数据集\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3) # 划分数据集\n",
    "model = SVC() # 创建支持向量机分类器模型\n",
    "model.fit(X_train, y_train) # 训练模型\n",
    "y_pred = model.predict(X_test) # 预测测试集\n",
    "accuracy_score(y_pred, y_test) # 计算准确率"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "ml",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
